home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 5
/
Gekikoh Dennoh Club Vol. 5 (Japan).7z
/
Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin
/
internet
/
webx
/
jpged26s.lzh
/
Encode.s
< prev
next >
Wrap
Text File
|
1996-09-25
|
7KB
|
387 lines
*
*
* ENCODE.S
*
* ânâtâ}âôòäìåë╗
*
include DOSCALL.MAC
include JPEG.MAC
include work.inc
*
.text
.xref ZigzagL 'MES.S'
.xref PrintWI 'Load.s'
.xref PrintHex
.xref CRLF
******************************************************************************
*
* DCɼò¬┤▌║░─▐Åêù¥╧╕█
*
* âWâOâUâOâXâLâââô
* ù╩Äqë╗
* æOë±é╠écébÆlé╞é╠ì╖é≡ĵéΘ
*
******************************************************************************
ENCODE_DC macro
*âWâOâUâOâXâLâââôé╞ù╩Äqë╗
*-----------------------
move.w (a5)+,d4 *QtableÆlô╟é▌ì₧é▌
move.w d4,d3
lsr.w #1,d3
move.w (a0),d0 *ù╩Äqë╗æOé╠écébÆl
bmi 1f
add.w d3,d0 *É│é╚éτÅñé╔+0.5
moveq.l #0,d3
1:
sub.w d3,d0 *òëé╚éτÅñé╔-0.5
ext.l d0
divs d4,d0 * d0.w = ìíë±é╠écéb
*æOë±é╠écébÆlé╞é╠ì╖é≡ĵéΘ
*------------------------
move.w (a1),d1 * æOë±é╠écéb
move.w d0,(a1)
moveq.l #0,d2
sub.w d1,d0
beq 3f
move.w d0,d1
bpl 2f
neg.w d1
subq.w #1,d0
2:
addq.w #4,d2
lsr.w #1,d1
bne 2b
3:
endm
******************************************************************************
*
* ACɼò¬┤▌║░─▐Åêù¥╧╕█
*
* âWâOâUâOâXâLâââô
* ù╩Äqë╗
* éOé╠î┬Éö╢│▌─
* EOB,ZRL┴¬»╕
******************************************************************************
ENCODE_AC macro SubAC,SubACZRL,SubACEOB
local ac10,ac20,ac50,ac90
lea.l ACLtable-DCLtable(a2),a2
lea.l ZigzagL(pc),a1
moveq.l #63-1,d2
ac10
move.w d2,d1 * RUN
ac20
*âWâOâUâOâXâLâââôé╞ù╩Äqë╗
*-----------------------
move.w (a5)+,d4 *QtableÆlô╟é▌ì₧é▌
move.w d4,d3
lsr.w #1,d3
adda.w (a1)+,a0 *Zigzag├░╠▐┘ô╟é▌ì₧é▌
move.w (a0),d0
*żÉöô_ê╚ë║ÄlÄ╠î▄ôⁿ
*---------------
bmi @f
add.w d3,d0
moveq.l #0,d3
@@
sub.w d3,d0
ext.l d0
divs.w d4,d0
*éOé╠î┬ÉöâJâEâôâg
*-----------------------
bne ac50
dbra d2,ac20
bsr SubACEOB * EOB
bra ac90
*éOê╚èOé╠é`ébÆlé¬Åoé─é½é╜
*-------------------
ac50
move.w d0,-(sp) * AC
sub.w d2,d1
@@
cmp.w #15,d1
bls @f
bsr SubACZRL * ZRL
sub.w #16,d1
bra @b
@@
move.w d1,-(sp) * Run
bsr SubAC
addq.l #4,sp
dbra d2,ac10
*
ac90
endm
*
*
*ü@ânâtâ}âôòäìåì┼ôKë╗é╠é╜é▀üAèeÆlé╠Åoî╗öΣùªîvæ¬
*
* a0.l âfü[â^ù╠êµ
* a1.l æOë±é╠écébù╠êµüiÄgùpîπé═üAZigzag├░╠▐┘âAâhâîâX)
* a2.l écébâRü[âhò\
* a5.l QtableâAâhâîâX
.xdef ENCODE1
ENCODE1
ENCODE_DC
add.w d2,d2
addq.l #1,(a2,d2.w) *èe╦▐»─Æ╖é╠Åoî╗ùªé≡ë┴ÄZ
ENCODE_AC countAC,countACZRL,countACEOB
moveq.l #0,d0
rts
******** ZRL
countACZRL
addq.l #1,15*16*8(a2) *èe╦▐»─Æ╖é╠Åoî╗ùªé≡ë┴ÄZ
rts
******** EOB
countACEOB
addq.l #1,(a2) *èe╦▐»─Æ╖é╠Åoî╗ùªé≡ë┴ÄZ
rts
* pushw AC(w)
* pushw RUN(w)
countAC
move.w 4(sp),d0
lsl.w #7,d0
move.w 6(sp),d1 * AC
bpl @f
neg.w d1
@@
addq.w #8,d0
lsr.w #1,d1
bne @b
addq.l #1,0(a2,d0.w)
rts
*
*
*
* ânâtâ}âôòäìåÅoù═
*
*
* a0.l âfü[â^ù╠êµ
* a1.l æOë±é╠écébù╠êµüiÄgùpîπé═üAZigzag├░╠▐┘âAâhâîâX)
* a2.l écébâRü[âhò\
* a4.l âoâbâtâ@ü[âAâhâîâX
* a5.l QtableâAâhâîâX
*
* d7.w ndata âoâbâtâ@ü[ôαâfü[â^Éö
* d6.w rlen ÄcéΦârâbâgÆ╖
* d5.l Åπê╩âÅü[âh rdata
* ÄcéΦâfü[â^
*
*
.xdef ENCODE
ENCODE
tst.w EncodePath(a6)
bnz ENCODE1
*Åæé½ì₧é▌╩▐»╠ºÉºîΣ┌╝▐╜└ò£ïA
*------------------------
move.w LastBufSize(a6),d7
move.w rlen(a6),d6
move.w rdata(a6),d5
swap d5
move.l bufadr(a6),a4
* écébɼò¬é╠Åoù═
*-------------------------
ENCODE_DC
move.w 0(a2,d2.w),d5 * code
move.w 2(a2,d2.w),d4 * length
bsr PutC
lsr.w #2,d2
beq dc_end
moveq.l #16,d1
sub.w d2,d1
lsl.w d1,d0
move.w d0,d5
move.w d2,d4
bsr PutC
dc_end
* é`ébɼò¬é╠Åoù═
*------------------------
ENCODE_AC PutAC,PutACZRL,PutACEOB
*Åæé½ì₧é▌╩▐»╠ºÉºîΣ┌╝▐╜└ò█æ╢
*------------------------
move.l a4,bufadr(a6)
swap d5
move.w d5,rdata(a6)
move.w d6,rlen(a6)
move.w d7,LastBufSize(a6)
move.l errflg(a6),d0
rts
*
* é`ébÅoù═òΓÅòÅoù═
*
* a3.l Huffman Table
*
******** ZRL
PutACZRL
move.w 15*16*4(a2),d5
move.w 15*16*4+2(a2),d4
bra PutC
******** EOB
PutACEOB
move.w (a2),d5
move.w 2(a2),d4
bra PutC
********
* pushw AC(w)
* pushw RUN(w)
PutAC
move.l d2,-(sp)
moveq.l #0,d2
move.w 10(sp),d0 * AC
move.w d0,d1
bpl @f
subq.w #1,d0
neg.w d1
@@
addq.w #4,d2
lsr.w #1,d1
bne @b
move.w 8(sp),d3
lsl.w #6,d3
add.w d2,d3
move.w 0(a2,d3.w),d5 * code
move.w 2(a2,d3.w),d4 * length
bsr PutC
lsr.w #2,d2
moveq.l #16,d3
sub.w d2,d3
lsl.w d3,d0
move.w d0,d5
move.w d2,d4
move.l (sp)+,d2
*
* âRü[âhÅoù═
* d5.w code(w)
* d4.w lengh(w)
*
PutC
cmp.w d4,d6
bls putc50
***** Åoù═é╚é╡
lsl.l d4,d5
sub.w d4,d6
rts
putc50
lsl.l d6,d5
sub.w d6,d4
moveq.l #8,d6
bsr PutB
*
putc60
cmp.w d6,d4
bcs putc70
lsl.l d6,d5
sub.w d6,d4
bsr PutB
bra putc60
putc70
lsl.l d4,d5
sub.w d4,d6
rts
*
* d5.l:l ôⁿù═âfü[â^üBÅπê╩âÅü[âhÅoù═
*
PutB
swap d5
cmp.b #$FF,d5
bne putb20
move.b d5,(a4)+
clr.w d5
dbra d7,putb20
move.l d0,-(sp)
move.l buf_size(a6),d7
move.l d7,-(sp)
subq.l #1,d7
move.l buf_adrs(a6),a4
move.l a4,-(sp)
move.w Jhandle(a6),-(sp)
dos _WRITE
move.l d0,errflg(a6) * I/O error
lea 10(sp),sp
move.l (sp)+,d0
putb20
move.b d5,(a4)+
dbra d7,putb80
move.l d0,-(sp)
move.l buf_size(a6),d7
move.l d7,-(sp)
subq.l #1,d7
move.l buf_adrs(a6),a4
move.l a4,-(sp)
move.w Jhandle(a6),-(sp)
dos _WRITE
move.l d0,errflg(a6) * I/O error
lea 10(sp),sp
move.l (sp)+,d0
putb80
swap d5
rts
*
* d0.w Handle
*
*
.xdef preENCODE
preENCODE
clr.l errflg(a6) * I/O error flag
clr.w preDC(a6)
clr.l preDC+2(a6)
clr.w rdata(a6)
move.w #8,rlen(a6)
move.l buf_size(a6),d0
subq.l #1,d0
move.w d0,LastBufSize(a6)
move.l buf_adrs(a6),bufadr(a6)
rts
*
.xdef postENCODE
postENCODE
movem.l d1/a0,-(sp)
move.l bufadr(a6),a4
moveq.l #0,d7
move.w LastBufSize(a6),d7
move.w rlen(a6),d1
cmp.w #8,d1
beq postEncode50
moveq.l #-1,d0
move.w rdata(a6),d0
rol.l d1,d0
move.b d0,(a4)+
subq.w #1,d7
postEncode50
move.l buf_size(a6),d0
subq.l #1,d0
sub.l d7,d0
beq postEncode90
move.l d0,-(sp)
move.l buf_adrs(a6),-(sp)
move.w Jhandle(a6),-(sp)
dos _WRITE
move.l d0,errflg(a6) * I/O error
lea 10(sp),sp
postEncode90
movem.l (sp)+,d1/a0
move.l errflg(a6),d0
rts
*
.end